package com.itfreer.knowledge.service.config;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.itfreer.form.api.BaseDao;
import com.itfreer.form.api.imp.DictionaryServiceImp;
import com.itfreer.form.dictionary.base.DictionaryItem;
import com.itfreer.knowledge.dao.config.CatalogDao;
import com.itfreer.knowledge.entity.config.CatalogEntity;

/**
 * 知识目录
 */
@Component("CatalogServiceImp")
public class CatalogServiceImp extends DictionaryServiceImp<CatalogEntity> implements CatalogService {

	@Autowired
	private CatalogDao catalogDao;
	
	@Override
	public String getDictionaryName() {
		return "knowledge_catalog";
	}

	@Override
	protected DictionaryItem convert(CatalogEntity entity) {
		DictionaryItem toEntity = new DictionaryItem();
		BeanUtils.copyProperties(entity, toEntity);
		toEntity.getOther().put("siteId", entity.getSiteId());
		toEntity.getOther().put("createDate", entity.getCreateDate());
		toEntity.getOther().put("recommend", entity.getRecommend());
		toEntity.getOther().put("image", entity.getImage());
		return toEntity;
	}

	@Override
	protected String getDictionaryFields() {
		return "id,pid,display,code,valid,leaf,siteId,createDate,recommend,image";
	}

	@Override
	protected BaseDao<CatalogEntity> getDao() {
		return catalogDao;
	}
	
}
